#include "Angel.h"


using namespace std;

class BoundingBox{
public:
	BoundingBox()
	{
		reset();
	}
	void update(point4 point)
	{
		if(isInit==false)
		{
			_max = point3(point.x,point.y,point.z);
			_min = point3(point.x,point.y,point.z);
			isInit = true;
			
		}
		else
		{
			if(point.x > _max.x){_max.x = point.x;}
			if(point.y > _max.y){_max.y = point.y;}
			if(point.z > _max.z){_max.z = point.z;}
			if(point.x < _min.x){_min.x = point.x;}
			if(point.y < _min.y){_min.y = point.y;}
			if(point.z < _min.z){_min.z = point.z;}
		}
	}

	void reset()
	{
		_max = point3(0.0f,0.0f,0.0f);
		_min = point3(0.0f,0.0f,0.0f);
		isInit = false;
		isOK = false;
	}

	point3 getMax()
	{
		return _max;
	}

	point3 getMin()
	{
		return _min;
	}

	point4 getCenter()
	{
		point4 center = point4((_max.x+_min.x)/2.0f,(_max.y+_min.y)/2.0f,(_max.z+_min.z)/2.0f,1.0f);
		return center;
	}

	point4 getBestEye()
	{
		float zOffset = 5.0f;
		point4 bestEye = point4((_max.x+_min.x)/2.0f,(_max.y+_min.y)/2.0f,(_max.z+_min.z)/2.0f+zOffset,1.0f);//z issue needs modification
		return bestEye;
	}

	void setOK(bool ok)
	{
		isOK = ok;
	}

	float getRange()
	{
		float xRange = _max.x-_min.x;
		float yRange = _max.y-_min.y;
		if(xRange > yRange)
			return xRange;
		else
			return yRange;
	}

	bool ok()
	{
		return isOK;
	}

private:
	point3 _max;
	point3 _min;
	bool isInit;
	bool isOK;

};

